package com.zjht.gmcc.servlet.sys;

import java.io.PrintWriter;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.zjht.gmcc.bean.BaseServlet;
import com.zjht.gmcc.bean.util.MyJDBC;

/**
 * @author Administrator TODO To change the template for this generated type comment go to Window - Preferences - Java -
 *         Code Style - Code Templates
 */
public class OpersSelect extends BaseServlet {

	private static final long serialVersionUID = 1L;

	public boolean process(HttpServletRequest request, HttpServletResponse response,
			HttpSession session, PrintWriter out, MyJDBC myJDBC,  String menu)
			throws Exception {
		response.setContentType("text/xml;charset=UTF-8");
		response.setHeader("Cache-Control", "no-cache");

		String s_orgatypeid = request.getParameter("zzlxid").trim();
		StringBuilder sb = new StringBuilder("<state>");
		sb.append("<value>00</value>");
		sb.append("<text>请选择</text>");

		String s_sql = null;
		PreparedStatement ps = null;
		ResultSet rs = null;
		s_sql = "select orgatypeid,DUTYID,DEPTNAME,dutyname from v_duty where orgatypeid=? order by dutyid";
		ps = myJDBC.prepareStatement(s_sql);
		ps.setString(1, s_orgatypeid);
		rs = ps.executeQuery();
		while (rs.next()) {
			sb.append("<value>" + rs.getString(2) + "</value>");
			sb.append("<text>" + rs.getString(3) + "-" + rs.getString(4) + "</text>");
		}

		s_sql = null;
		rs.close();
		rs = null;
		ps.close();
		ps = null;
		sb.append("</state>");
		out.write(sb.toString());
		return true;
	}
}
